<?php

namespace YouBaoLian\Application\Request;

use YouBaoLian\Application\Response\VehicleSubmitUnderWriteResponse;

class VehicleSubmitUnderWriteRequest extends Request
{
    private $configId = 0;

    private $priceItemId = 0;

    private $payReturnUrl = '';

    private $invoiceType = '';

    private $bankName = '';

    private $accountNumber = '';

    private $identifyNumber = '';

    private $registerPhone = '';

    private $registerAddress = '';

    private $email = '';

    private $insSpecialList = [];

    /**
     * customerId
     * @var int $customerId
     */
    private $customerId = 0;

    protected $method = 'iebcVehicle.submitUnderWrite';

    protected $response = VehicleSubmitUnderWriteResponse::class;

    public function getBizContent(): array
    {
        $data = [
            'configId' => $this->configId,
            'priceItemId' => $this->priceItemId,
        ];

        if ($this->payReturnUrl) {
            $data['payReturnUrl'] = $this->payReturnUrl;
        }

        if ($this->invoiceType) {
            $invoiceInfo = [
                'invoiceType' => $this->invoiceType,
                'bankName' => $this->bankName,
                'accountNumber' => $this->accountNumber,
                'identifyNumber' => $this->identifyNumber,
                'registerPhone' => $this->registerPhone,
                'registerAddress' => $this->registerAddress,
                'email' => $this->email
            ];
            $data['invoiceInfo'] = $invoiceInfo;
        }

        if ($this->insSpecialList) {
            $data['insSpecialClause'] = $this->insSpecialList;
        }

        if ($this->customerId) {
            $data['customerId'] = $this->customerId;
        }

        return $data;

    }

    public function append(
        int    $clauseId,
        string $clauseCode,
        string $clauseContent,
        string $clauseTitle,
        int    $insType,
        int    $clauseType,
        string $clauseFlag = '',
        string $clauseSerialNo = '',
        string $autoFlag = '0',
        string $startTime = '',
        string $endTime = ''

    )
    {
        $this->insSpecialList[] = [
            'clauseId' => $clauseId,
            'clauseCode' => $clauseCode,
            'clauseContent' => $clauseContent,
            'clauseTitle' => $clauseTitle,
            'insType' => $insType,
            'clauseType' => $clauseType,
            'clauseFlag' => $clauseFlag,
            'clauseSerialNo' => $clauseSerialNo,
            'autoFlag' => $autoFlag,
            'startTime' => $startTime,
            'endTime' => $endTime
        ];
    }

    /**
     * @param mixed $configId
     */
    public function setConfigId($configId): void
    {
        $this->configId = $configId;
    }

    /**
     * @param mixed $priceItemId
     */
    public function setPriceItemId($priceItemId): void
    {
        $this->priceItemId = $priceItemId;
    }

    /**
     * @param string $payReturnUrl
     */
    public function setPayReturnUrl(string $payReturnUrl): void
    {
        $this->payReturnUrl = $payReturnUrl;
    }

    /**
     * @param string $invoiceType
     */
    public function setInvoiceType(string $invoiceType): void
    {
        $this->invoiceType = $invoiceType;
    }

    /**
     * @param string $bankName
     */
    public function setBankName(string $bankName): void
    {
        $this->bankName = $bankName;
    }

    /**
     * @param string $accountNumber
     */
    public function setAccountNumber(string $accountNumber): void
    {
        $this->accountNumber = $accountNumber;
    }

    /**
     * @param string $identifyNumber
     */
    public function setIdentifyNumber(string $identifyNumber): void
    {
        $this->identifyNumber = $identifyNumber;
    }

    /**
     * @param string $registerPhone
     */
    public function setRegisterPhone(string $registerPhone): void
    {
        $this->registerPhone = $registerPhone;
    }

    /**
     * @param string $registerAddress
     */
    public function setRegisterAddress(string $registerAddress): void
    {
        $this->registerAddress = $registerAddress;
    }

    /**
     * @param string $email
     */
    public function setEmail(string $email): void
    {
        $this->email = $email;
    }

    /**
     * @param array $insSpecialList
     */
    public function setInsSpecialList(array $insSpecialList): void
    {
        $this->insSpecialList = $insSpecialList;
    }

    /**
     * @param int $customerId
     */
    public function setCustomerId(int $customerId): void
    {
        $this->customerId = $customerId;
    }
}
